package vn.edu.uit.hotelbooking.activity;

import java.util.ArrayList;

import vn.edu.uit.hotelbooking.R;
import vn.edu.uit.hotelbooking.model.Country;
import vn.edu.uit.hotelbooking.model.District;
import vn.edu.uit.hotelbooking.model.Hotel;
import vn.edu.uit.hotelbooking.model.Province;
import vn.edu.uit.hotelbooking.model.User;
import vn.edu.uit.hotelbooking.model.Ward;
import vn.edu.uit.service.fetchers.CountryFetcher;
import vn.edu.uit.service.fetchers.DistrictFetcher;
import vn.edu.uit.service.fetchers.LocationFetcher;
import vn.edu.uit.service.fetchers.ProvinceFetcher;
import vn.edu.uit.service.fetchers.TestFetcher;
import vn.edu.uit.service.fetchers.UserInfoFetcher;
import vn.edu.uit.service.fetchers.WardFetcher;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Window;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

public class SearchActivity extends Activity {
    private TextView tvLocationValue;
    private TextView tvTime;
    private TextView tvNumberRooms;
    private TextView tvPeoplePerRoom;
    private TextView tvResultValue;
    private Button btnFilter;
    private Button btnSort;
    private ListView lvHotel;
    private ProgressDialog dialog;
    private ArrayList<Hotel> listHotel = new ArrayList<Hotel>();
    /** The handler to process  */
    Handler handler = new Handler(){

        /* (non-Javadoc)
         * @see android.os.Handler#handleMessage(android.os.Message)
         */
        @Override
        public void handleMessage(Message msg) {
            // TODO Auto-generated method stub
            super.handleMessage(msg);
            dialog.dismiss();
            /*HotelAdapter adapter = new HotelAdapter(getApplicationContext(), R.layout.hotel_item, listHotel);
            lvHotel.setAdapter(adapter);*/
        }
    };
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.search_result_activity);
        tvLocationValue = (TextView)findViewById(R.id.tvLocationValue_SearchResult);
        tvTime = (TextView)findViewById(R.id.tvTimeValue_SearchResult);
        tvNumberRooms = (TextView)findViewById(R.id.tvNumberRooms_SearchResult);
        tvPeoplePerRoom = (TextView)findViewById(R.id.tvPeoplePerRomsValue_SearchResult);
        tvResultValue = (TextView)findViewById(R.id.tvResultValue_SearchResult);
        btnFilter = (Button)findViewById(R.id.btnFilter_SearchResult);
        btnSort = (Button)findViewById(R.id.btnSort_SearchResult);
        lvHotel = (ListView)findViewById(R.id.lvHotel);
        dialog = ProgressDialog.show(SearchActivity.this, "Loadding", "Get hotel...");
        new Thread(new Runnable() {
            
            @Override
            public void run() {
                // TODO Auto-generated method stub                        
                //send request to server to check login
                //listHotel = HotelFetcher.getDistrict();
                ArrayList<Country> country = LocationFetcher.getCountry();
                ArrayList<Province> province = LocationFetcher.getProvince("1");
                ArrayList<District> district = LocationFetcher.getDistrict("01");
                ArrayList<Ward> ward = LocationFetcher.getWard("001");
                User user = UserInfoFetcher.getUserInfo();
                
                TestFetcher.getPermisionIsPublic();
                TestFetcher.getAccommodations();
                TestFetcher.getSexUser();
                TestFetcher.getThemesHotel();
                TestFetcher.getAmenitiesHotel();
                handler.sendEmptyMessage(0);                 
            }
        }).start();
        
    }

}
